<template>
  <div id="app">
    <router-view/>
    <uiDialog :data="ruleDialogData">
      <p>1.	每道答题时间为30秒，20道题目总时长10分钟；</p>
      <p>2.	每答对一题获得10分，满分200分；</p>
      <p>3.	游戏完成后，可获得相应积分；</p>
      <p>4.	积分可以用于抽取答题道具，道具能在答题时使用，具体如下：</p>
      <p>　A. 去错卡：去掉1个错误答案；</p>
      <p>　B. 加时卡：加时60秒；</p>
      <p>　C. 跳过此题卡：直接跳过此题；</p>
      <p>　D. 积分翻倍卡：总积分翻倍。</p>
      <p>5.	不定期发布积分兑换实物，请随时关注；</p>
      <p>6.	兑换的实物请在领取页面查看领奖方式及地址；</p>

    </uiDialog>
    <uiDialog :data="alertData"></uiDialog>
  </div>
</template>

<script>
  import uiDialog from './components/dialog.vue'
  import axios from 'axios'
  import utils from './assets/script/utils'

  // 朋友访问页面
  export default {
    name: 'app',
    data:function () {
      return {}
    },
    computed: {
      ruleDialogData(){
        return {
          title: '游戏规则',
          visible: this.$store.state.isShowRule,
          btns:['确定'],
          callback: (e) => {
            this.$store.commit('hideRule')
          }
        }
      },
      alertData(){
        return this.$store.state.alertData
      }
    },
    mounted(){
      axios.get('/gxtest/getUserInfo').then(res=>{

        if(res.data.openid!=utils.querys.friendopenid){
          // 判断为非本人进入页面
          window.href = "http://game.lzsunspot.com/gxtest/wxOauth"
        }

        this.$store.commit('setUserInfo',res.data)
        if (res.data === '') {
          // this.$router.replace({path: '/web/wxOauth?url=' + encodeURI(window.location.href)})
          window.location.href = '/gxtest/wxOauth?url=' + encodeURI(window.location.href)
        }
      })
      axios.get('/gxtest/getTest').then(res=>{
        this.$store.commit('setTest',res.data.test)
        this.$store.commit('setQuestions',res.data.questions)
        if(res.data.test.isjoin > 0 && this.$route.name != 'result'){
          this.$router.push('result')
        }else if(res.data.test.isjoin == 0){
          if(this.$route.name!='cover'){
            this.$router.push({name:'cover'})
          }
        }
      })
    },
    components: {uiDialog}
  }
</script>

<style>
  @import "assets/style/common.css";
  #app {
    font-family: 'Avenir', Helvetica, Arial, sans-serif;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
</style>
